package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.server.enums.SexEnum;
import com.tanhua.server.mapper.UserInfoMapper;
import com.tanhua.server.pojo.User;
import com.tanhua.server.pojo.UserInfo;
import com.tanhua.server.utils.UserThreadLocal;
import com.tanhua.server.vo.UserInfoVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: Administrator
 * @date: Created in 2021/2/15 14:08
 * @version: 0.0.1
 * @modified By:
 */
@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public Boolean updateUserInfoByUserId(UserInfo userInfo){
        QueryWrapper<UserInfo>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",userInfo.getUserId());
        return this.userInfoMapper.update(userInfo,queryWrapper)>0;
    }

    public UserInfo queryUserInfoByUserId(Long userId) {
        QueryWrapper<UserInfo>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return this.userInfoMapper.selectOne(queryWrapper);
    }

    public List<UserInfo> queryUserInfoList(QueryWrapper<UserInfo>queryWrapper) {
        return this.userInfoMapper.selectList(queryWrapper);
    }
}
